<?php

namespace app\common\model;

use think\Model;


class Distribution extends Model
{





    // 表名
    protected $name = 'distribution_mode';

    // 自动写入时间戳字段
    protected $autoWriteTimestamp = false;

    // 定义时间戳字段名
    protected $createTime = false;
    protected $updateTime = false;
    protected $deleteTime = false;

    // 追加属性
    protected $append = [
        'child'
    ];

    protected static function init()
    {
        self::afterInsert(function ($row) {
            $row->save(['weigh' => $row['id']]);
        });
    }

    public function getChildAttr($v, $d)
    {
        return self::all(['pid' => $d['id']]);
    }
}
